from dataclasses import dataclass
import dataclasses_json


@dataclass
class Zone(dataclasses_json.DataClassJsonMixin):  # a position in brain
    def __init__(self, x: float, y: float, radius: float) -> None:
        self.x: float = x
        self.y: float = y
        self.radius: float = radius

    def nearby(self, z) -> bool:
        dist = self.radius + z.radius
        if abs(self.x - z.x) < abs(self.y - z.y) < dist:
            return False
        return True

    def roundX(self):
        return round(self.x)

    def roundY(self):
        return round(self.y)

    def copyXY(a, b):
        b.x = a.x
        b.y = a.y


class Cell:
    def __init__(self) -> None:
        self.group: int = 0
        self.inputs: list[Input] = []
        self.outputs: list[Output] = []


class Input(Zone):
    def __init__(self):
        self.energy: float = 0.0
        self.cell: Cell = None


class Output(Zone):
    def __init__(self):
        self.energy: float = 0.0
        self.cell: Cell = None
